package com.tanhua.dubbo.api.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.domain.db.Questions;

import com.tanhua.dubbo.api.QuestionsApi;
import com.tanhua.dubbo.mapper.CoverMapper;
import com.tanhua.dubbo.mapper.QuestionsMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class QuestionsImpl implements QuestionsApi {
    @Autowired
    private QuestionsMapper questionsMapper;
    @Autowired
    private CoverMapper coverMapper;

    @Override
    public List<Questions> findQuestions(Integer testId) {
        QueryWrapper<Questions> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("test_id", testId);

        return questionsMapper.selectList(queryWrapper);
    }

    @Override
    public String findLevel(String questionId) {
        Questions questions = questionsMapper.selectById(questionId);
        return coverMapper.selectById(questions.getTestId()).getLevel();
    }
}
